package leetcode.L500;

import java.util.Arrays;

public class Ex179 {
    public String largestNumber(int[] nums) {

        String[] s = new String[nums.length];
        String res = "";

        for (int i = 0; i < nums.length; i++) {
            s[i] =String.valueOf(nums[i]);
        }
        Arrays.sort(s,(a,b)->{
            String s1 = a+b;
            String s2 = b+a;
            return s2.compareTo(s1);
        });

        for (String s1 : s) {
            res = res+s1;
        }
        if(res.charAt(0)=='0'){
            return "0";
        }
        return res;
    }
}
